﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Commctrol_oldSearchLead : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BandingSeachInfo();
        }
    }

    private void BandingSeachInfo()
    {
        ltHouseShape.Text = getStrByType(0, getLouCheng());
        ltPurpose.Text = getStrByType(1, getPurpose());
        ltfimat.Text = getStrByType(2, getFitment());
        ltUnit.Text = getStrByType(3, getUnit());
        ltArea.Text = getStrByType(4, getArea());
        if (!string.IsNullOrEmpty(strArea))
        {
            ltCricle.Text = getStrByArea(5, int.Parse(strArea));
        }

        ltSize.Text = getStrByType(6, getSize());
        ltPrice.Text = getStrByType(7, getPrice());

    }


    private string getStrByArea(int typeid, int AreaId)
    {
        try
        {
            return getStrByType(typeid, (SortedList)getCricleList()[AreaId]);
        }
        catch
        {
            return "";
        }

    }

    private string getStrByType(int typeId, SortedList SLTypeInfo)
    {
        string strLCFomat = @"<span class=""oranges12_cu"">{0}</span> <span class=""blue_link"">{1}</span>";
        string strAFomat = @"<a href=""ErShouFang.aspx?floor={0}&purpose={1}&fitment={2}&unit={3}&area={4}&circle={5}&size={6}&price={7}"" >{8}</a>";
        string strActive = "<font color=#FF6600>{0}</font>";
        //点击楼层发生的事情
        string strInfo = string.Empty;
        string strAll = string.Empty;

        foreach (int key in SLTypeInfo.Keys)
        {
            switch (typeId)
            {
                case 0:
                    if (key.ToString() == strHouseShape)
                    {
                        strInfo += string.Format(strActive, SLTypeInfo[key].ToString());
                        strAll = string.Format(strAFomat, "", strPurpose, strFitment, strUnit, strArea, strCircle, strSize, strPrice, "不限");
                    }
                    else
                    {
                        strInfo += string.Format(strAFomat, key, strPurpose, strFitment, strUnit, strArea, strCircle, strSize, strPrice, SLTypeInfo[key].ToString());

                    }
                    break;
                case 1:
                    if (key.ToString() == strPurpose)
                    {
                        strInfo += string.Format(strActive, SLTypeInfo[key].ToString());
                        strAll = string.Format(strAFomat, strHouseShape, "", strFitment, strUnit, strArea, strCircle, strSize, strPrice, "不限");
                    }
                    else
                    {
                        strInfo += string.Format(strAFomat, strHouseShape, key, strFitment, strUnit, strArea, strCircle, strSize, strPrice, SLTypeInfo[key].ToString());

                    }
                    break;
                case 2:
                    if (key.ToString() == strFitment)
                    {
                        strInfo += string.Format(strActive, SLTypeInfo[key].ToString());
                        strAll = string.Format(strAFomat, strHouseShape, strPurpose, "", strUnit, strArea, strCircle, strSize, strPrice, "不限");
                    }
                    else
                    {
                        strInfo += string.Format(strAFomat, strHouseShape, strPurpose, key, strUnit, strArea, strCircle, strSize, strPrice, SLTypeInfo[key].ToString());

                    }
                    break;
                case 3:
                    if (key.ToString() == strUnit)
                    {
                        strInfo += string.Format(strActive, SLTypeInfo[key].ToString());
                        strAll = string.Format(strAFomat, strHouseShape, strPurpose, strFitment, "", strArea, strCircle, strSize, strPrice, "不限");
                    }
                    else
                    {
                        strInfo += string.Format(strAFomat, strHouseShape, strPurpose, strFitment, key, strArea, strCircle, strSize, strPrice, SLTypeInfo[key].ToString());

                    }
                    break;
                case 4:
                    if (key.ToString() == strArea)
                    {
                        strInfo += string.Format(strActive, SLTypeInfo[key].ToString());
                        strAll = string.Format(strAFomat, strHouseShape, strPurpose, strFitment, strUnit, "", "", strSize, strPrice, "不限");
                    }
                    else
                    {
                        strInfo += string.Format(strAFomat, strHouseShape, strPurpose, strFitment, strUnit, key, "", strSize, strPrice, SLTypeInfo[key].ToString());

                    }
                    break;
                case 5:
                    if (key.ToString() == strCircle)
                    {
                        strInfo += string.Format(strActive, SLTypeInfo[key].ToString());
                        strAll = string.Format(strAFomat, strHouseShape, strPurpose, strFitment, strUnit, strArea, "", strSize, strPrice, "不限");
                    }
                    else
                    {
                        strInfo += string.Format(strAFomat, strHouseShape, strPurpose, strFitment, strUnit, strArea, key, strSize, strPrice, SLTypeInfo[key].ToString());

                    }
                    break;
                case 6:
                    if (key.ToString() == strSize)
                    {
                        strInfo += string.Format(strActive, SLTypeInfo[key].ToString());
                        strAll = string.Format(strAFomat, strHouseShape, strPurpose, strFitment, strUnit, strArea, strCircle, "", strPrice, "不限");
                    }
                    else
                    {
                        strInfo += string.Format(strAFomat, strHouseShape, strPurpose, strFitment, strUnit, strArea, strCircle, key, strPrice, SLTypeInfo[key].ToString());

                    }
                    break;
                case 7:
                    if (key.ToString() == strPrice)
                    {
                        strInfo += string.Format(strActive, SLTypeInfo[key].ToString());
                        strAll = string.Format(strAFomat, strHouseShape, strPurpose, strFitment, strUnit, strArea, strCircle, strSize, "", "不限");
                    }
                    else
                    {
                        strInfo += string.Format(strAFomat, strHouseShape, strPurpose, strFitment, strUnit, strArea, strCircle, strSize, key, SLTypeInfo[key].ToString());

                    }
                    break;
            }
        }

        if (string.IsNullOrEmpty(strAll))
        {
            strAll = "不限";
        }

        return string.Format(strLCFomat, strAll, strInfo);
    }


    private SortedList getLouCheng()
    {
        SortedList SlLoucheng = new SortedList();
        SlLoucheng.Add(1, "低层");
        SlLoucheng.Add(2, "中低层");
        SlLoucheng.Add(3, "小高层");
        SlLoucheng.Add(4, "高层");
        SlLoucheng.Add(5, "超高层");
        return SlLoucheng;

    }

    private SortedList getPurpose()
    {
        SortedList SlPurpose = new SortedList();
        SlPurpose.Add(1, "住宅");
        SlPurpose.Add(2, "别墅");
        SlPurpose.Add(3, "写字楼");
        SlPurpose.Add(4, "商铺");
        SlPurpose.Add(5, "其他");
        return SlPurpose;
    }

    private SortedList getFitment()
    {
        SortedList SlFitment = new SortedList();
        SlFitment.Add(1, "毛坯");
        SlFitment.Add(2, "普通装修");
        SlFitment.Add(3, "精装修");
        SlFitment.Add(4, "豪华装修");
        return SlFitment;
    }


    private SortedList getUnit()
    {
        SortedList SlUnit = new SortedList();
        SlUnit.Add(1, "1室");
        SlUnit.Add(2, "2室");
        SlUnit.Add(3, "3室");
        SlUnit.Add(4, "4室");
        SlUnit.Add(5, "5室");
        SlUnit.Add(6, "6室");
        SlUnit.Add(7, "7室");
        SlUnit.Add(8, "8室");
        SlUnit.Add(9, "其他");
        return SlUnit;

    }

    private SortedList getSize()
    {
        SortedList SlSize = new SortedList();
        SlSize.Add(1, "60M²以下");
        SlSize.Add(2, "60-70M²");
        SlSize.Add(3, "70-80M²");
        SlSize.Add(4, "80-90M²");
        SlSize.Add(5, "90-100M²");
        SlSize.Add(6, "100-120M²");
        SlSize.Add(7, "120-150M²");
        SlSize.Add(8, "150M²以上");

        return SlSize;

    }

    private SortedList getPrice()
    {
        SortedList SlPrice = new SortedList();
        SlPrice.Add(1, "30万以下");
        SlPrice.Add(2, "30-50万");
        SlPrice.Add(3, "50-80万");
        SlPrice.Add(4, "80-100万");
        SlPrice.Add(5, "100-150万");
        SlPrice.Add(6, "150-250万");
        SlPrice.Add(7, "250-300万");
        SlPrice.Add(8, "300万以上");
        return SlPrice;
    }

    private SortedList getArea()
    {
        SortedList SlArea = new SortedList();
        SlArea.Add(1, "园区");
        SlArea.Add(2, "新区");
        SlArea.Add(3, "平江");
        SlArea.Add(4, "沧浪");
        SlArea.Add(5, "金闾");
        SlArea.Add(6, "吴中");
        SlArea.Add(7, "相城");
        SlArea.Add(8, "昆山");
        SlArea.Add(9, "太仓");
        SlArea.Add(10, "张家港");
        SlArea.Add(11, "吴江");
        return SlArea;
    }

    private Hashtable getCricleList()
    {
        Hashtable ht = new Hashtable();
        SortedList SlCricle = new SortedList();
        SlCricle.Add(1, "东环路");
        SlCricle.Add(2, "娄葑");
        SlCricle.Add(3, "湖东");
        SlCricle.Add(4, "湖西");
        SlCricle.Add(5, "独墅湖");
        SlCricle.Add(6, "胜浦");
        SlCricle.Add(7, "唯亭");
        SlCricle.Add(8, "青剑湖");
        ht.Add(1, SlCricle);
        SlCricle = new SortedList();
        SlCricle.Add(9, "狮山");
        SlCricle.Add(10, "阳山");
        SlCricle.Add(11, "横塘");
        SlCricle.Add(12, "浒墅关");
        SlCricle.Add(13, "通安");
        SlCricle.Add(14, "东渚");
        SlCricle.Add(15, "镇湖");
        SlCricle.Add(16, "科技城");
        SlCricle.Add(17, "枫桥");
        ht.Add(2, SlCricle);
        SlCricle = new SortedList();
        SlCricle.Add(18, "桃花坞");
        SlCricle.Add(19, "平江路");
        SlCricle.Add(20, "娄门");
        SlCricle.Add(21, "城北街道");
        SlCricle.Add(22, "苏锦街道");
        SlCricle.Add(23, "观前");
        ht.Add(3, SlCricle);
        SlCricle = new SortedList();
        SlCricle.Add(24, "南门");
        SlCricle.Add(25, "双塔");
        SlCricle.Add(26, "葑门");
        SlCricle.Add(27, "吴门桥");
        SlCricle.Add(28, "友新");
        SlCricle.Add(29, "胥江");
        ht.Add(4, SlCricle);
        SlCricle = new SortedList();
        SlCricle.Add(30, "彩香");
        SlCricle.Add(31, "石路");
        SlCricle.Add(32, "虎丘");
        SlCricle.Add(33, "白洋湾");
        SlCricle.Add(34, "留园");
        ht.Add(5, SlCricle);

        SlCricle = new SortedList();
        SlCricle.Add(35, "木渎");
        SlCricle.Add(36, "苏苑");
        SlCricle.Add(37, "龙西");
        SlCricle.Add(38, "长桥");
        SlCricle.Add(39, "城南");
        SlCricle.Add(40, "开发区");
        SlCricle.Add(41, "郭巷");
        SlCricle.Add(42, "甪直");
        SlCricle.Add(43, "胥口");
        SlCricle.Add(44, "横泾");
        SlCricle.Add(45, "临湖");
        SlCricle.Add(46, "东山");
        SlCricle.Add(47, "西山");
        SlCricle.Add(48, "香山");
        SlCricle.Add(49, "光福");
        SlCricle.Add(50, "越溪");
        ht.Add(6, SlCricle);

        SlCricle = new SortedList();
        SlCricle.Add(51, "陆慕");
        SlCricle.Add(52, "元和");
        SlCricle.Add(53, "开发区");
        SlCricle.Add(54, "太平");
        SlCricle.Add(55, "渭塘");
        SlCricle.Add(56, "阳澄湖");
        SlCricle.Add(57, "北桥");
        SlCricle.Add(58, "黄埭");
        SlCricle.Add(59, "望亭");
        ht.Add(7, SlCricle);
        return ht;
    }

    protected string RequestURL(string p_strID)
    {
        if (Request[p_strID] != null && Request[p_strID].ToString().Trim() != string.Empty)
        {
            return Request[p_strID].ToString().Trim();
        }
        else
        {
            return string.Empty;
        }
    }

    #region 属性
    protected string strHouseShape
    {
        get
        {
            return this.RequestURL("floor").ToString();
        }
    }

    protected string strPurpose
    {
        get
        {
            return this.RequestURL("purpose").ToString();
        }
    }

    protected string strFitment
    {
        get
        {
            return this.RequestURL("fitment").ToString();
        }
    }

    protected string strUnit
    {
        get
        {
            return this.RequestURL("unit").ToString();
        }
    }

    protected string strSize
    {
        get
        {
            return this.RequestURL("size").ToString();
        }
    }

    protected string strPrice
    {
        get
        {
            return this.RequestURL("price").ToString();
        }
    }


    protected string strArea
    {
        get
        {
            return this.RequestURL("area").ToString();
        }
    }

    protected string strCircle
    {
        get
        {
            return this.RequestURL("circle").ToString();
        }
    }

    #endregion
}
